diff --git a/board/hymod/fetch.c b/board/hymod/fetch.c
index dcbda31..e121d55 100644
--- a/board/hymod/fetch.c
+++ b/board/hymod/fetch.c
@@ -1,7 +1,6 @@
 /*
  * (C) Copyright 2001
- * Murray Jensen, CSIRO Manufacturing Science and Technology,
- * <Murray.Jensen@cmst.csiro.au>
+ * Murray Jensen, CSIRO-MIT, <Murray.Jensen@csiro.au>
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -25,118 +24,84 @@
 #include <common.h>
 #include <net.h>
 
-/* imports from common/main.c */
-extern char console_buffer[CFG_CBSIZE];
+/* imports from input.c */
+extern int hymod_get_ethaddr (void);
 
 int
-fetch_and_parse(bd_t *bd, char *fn, ulong addr, int (*cback)(uchar *, uchar *))
+fetch_and_parse (char *fn, ulong addr, int (*cback)(uchar *, uchar *))
 {
-    char *ethaddr;
-    uchar *fp, *efp;
+	char *ethaddr;
+	uchar *fp, *efp;
+	int rc, count = 0;
 
-    while ((ethaddr = getenv("ethaddr")) == NULL || *ethaddr == '\0') {
+	while ((ethaddr = getenv ("ethaddr")) == NULL || *ethaddr == '\0') {
 
-	puts("*** Ethernet address is not set\n");
+		printf ("*** Ethernet address is%s not set\n",
+			count == 0 ? "" : " STILL");
 
-	for (;;) {
-	    int n;
+		if ((rc = hymod_get_ethaddr ()) < 0) {
+			if (rc == -1)
+				puts ("\n*** interrupted!");
+			else
+				puts ("\n*** timeout!");
+			printf (" - fetch of '%s' aborted\n", fn);
+			return (0);
+		}
 
-	    n = readline("Enter board ethernet address: ");
+		count++;
+	}
 
-	    if (n < 0) {
-		puts("\n");
+	copy_filename (BootFile, fn, sizeof (BootFile));
+	load_addr = addr;
+	NetBootFileXferSize = 0;
+
+	if (NetLoop (TFTP) == 0) {
+		printf ("tftp transfer of file '%s' failed\n", fn);
 		return (0);
-	    }
-
-	    if (n == 0)
-		continue;
-
-	    if (n == 17) {
-		int i;
-		char *p, *q;
-		uchar ea[6];
-
-		/* see if it looks like an ethernet address */
-
-		p = console_buffer;
-
-		for (i = 0; i < 6; i++) {
-		    char term = (i == 5 ? '\0' : ':');
-
-		    ea[i] = simple_strtol(p, &q, 16);
-
-		    if ((q - p) != 2 || *q++ != term)
-			break;
-
-		    p = q;
-		}
-
-		if (i == 6) {
-		    /* it looks ok - set it */
-		    printf("Setting ethernet address to %s\n", console_buffer);
-		    setenv("ethaddr", console_buffer);
-
-		    puts("Remember to do a 'saveenv' to make it permanent\n");
-		    break;
-		}
-	    }
-
-	    printf("Invalid ethernet address (%s) - please re-enter\n",
-		console_buffer);
-	}
-    }
-
-    copy_filename(BootFile, fn, sizeof (BootFile));
-    load_addr = addr;
-
-    if (NetLoop(TFTP) <= 0) {
-	printf("tftp transfer of file '%s' failed\n", fn);
-	return (0);
-    }
-
-    if (NetBootFileXferSize == 0) {
-	printf("can't determine size of file '%s'\n", fn);
-	return (0);
-    }
-
-    fp = (uchar *)load_addr;
-    efp = fp + NetBootFileXferSize;
-
-    do {
-	uchar *name, *value;
-
-	if (*fp == '#' || *fp == '\n') {
-	    while (fp < efp && *fp++ != '\n')
-		;
-	    continue;
 	}
 
-	name = fp;
+	if (NetBootFileXferSize == 0) {
+		printf ("can't determine size of file '%s'\n", fn);
+		return (0);
+	}
 
-	while (fp < efp && *fp != '=')
-	    if (*fp++ == '\n')
+	fp = (uchar *)load_addr;
+	efp = fp + NetBootFileXferSize;
+
+	do {
+		uchar *name, *value;
+
+		if (*fp == '#' || *fp == '\n') {
+			/* skip this line */
+			while (fp < efp && *fp++ != '\n')
+				;
+			continue;
+		}
+
 		name = fp;
 
-	if (fp >= efp)
-	    break;
+		while (fp < efp && *fp != '=' && *fp != '\n')
+			fp++;
+		if (fp >= efp)
+			break;
+		if (*fp == '\n') {
+			fp++;
+			continue;
+		}
+		*fp++ = '\0';
 
-	*fp++ = '\0';
+		value = fp;
 
-	value = fp;
+		while (fp < efp && *fp != '\n')
+			fp++;
+		if (fp[-1] == '\r')
+			fp[-1] = '\0';
+		*fp++ = '\0';	/* ok if we go off the end here */
 
-	while (fp < efp && *fp != '\n')
-	    fp++;
+		if ((*cback)(name, value) == 0)
+			return (0);
 
-	/* ok if we go off the end here */
+	} while (fp < efp);
 
-	if (fp[-1] == '\r')
-	    fp[-1] = '\0';
-	*fp++ = '\0';
-
-	if ((*cback)(name, value) == 0)
-	    return (0);
-
-    } while (fp < efp);
-
-    return (1);
+	return (1);
 }
